package com.kc.gb.device.controller;

import com.kc.gb.base.dto.Result;
import com.kc.gb.device.controller.dto.SlantCommandDto;
import com.kc.gb.device.service.SlantAdminService;
import com.kc.gb.device.service.support.dto.StationContainerSlotLayout;
import com.kc.gb.feign.slant.support.SlantCommand;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/admin/device/slant")
public class SlantAdminController {

    @Resource
    SlantAdminService adminService;

    @PostMapping(path = "/operation")
    private Result<?> getStationByDeviceCode(@RequestBody SlantCommandDto command) {
        boolean inDebugMode = command.isInDebugMode();
        List<SlantCommand> commands = new ArrayList<>();
        SlantCommand c = new SlantCommand();
        c.setStationCode(command.getStationCode());
        c.setPosition(command.getPosition());
        c.setType(command.getType());
        commands.add(c);
        adminService.consumeCommands(commands,inDebugMode);
        return Result.success();
    }

}
